/*
 * 
 */
package cz.muni.fi.pb138.accountingRecords;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Interface for Payment managment. Provides basic operations with payments.
 *
 * @author Jaroslav Klech
 */
public interface PaymentManager {
    
    /**
     * Method saves Payment into database.
     * 
     * @param payment Payment which should be saved into DB
     * @throws IllegalArgumentException if payment is already in database or
     * payment isn't valid
     * @throws ServiceFailureException if another error occurs
     */
    void addPayment(Payment payment);
    
    /**
     * Returns Payment with given id
     * 
     * @param id ID of payment in database
     * @return payment with given id or throws exception
     * @throws IllegalArgumentException if id is null or payment with given 
     * id isn't in database
     * @throws ServiceFailureException if another error occurs
     */
    Payment getPayment(String id);
    
    /**
     * Removes payment with given ID from database 
     * 
     * @param id ID of payment which should be removed
     * @throws IllegalArgumentException if id is null or payment with given 
     * id isn't in database
     * @throws ServiceFailureException if another error occurs
     */
    void removePayment(String id);
    
    /**
     * Updates payment which is already in database
     * 
     * @param payment Payment which should be updated
     * @throws IllegalArgumentException if payment is null or payment isn't 
     * in database or payment isn't valid
     * @throws ServiceFailureException if another error occurs
     */
    void updatePayment(Payment payment);
    
    /**
     * Returns List of payment for specific time period
     * 
     * @param from Date from which should be payments chosen 
     * @param to Date to which should be payments chosen 
     * @return Returns list of payments for specific period, empty list when
     * there is no payment or exception
     * @throws IllegalArgumentException if from date or to date is null
     * @throws ServiceFailureException if another error occurs
     */
    List<Payment> getPaymentsForPeriod(Date from, Date to);
    
    /**
     * Returns sum of amount for spacific time period
     * 
     * @param from Date from which should be payments chosen 
     * @param to Date to which should be payments chosen
     * @return sum of amount for payments
     * @throws IllegalArgumentException if from date or to date is null
     * @throws ServiceFailureException if another error occurs
     */
    BigDecimal paymentSum(Date from, Date to);
    
}
